package com.hxd.mall.wxapi

import android.content.Context
import com.hxd.mall.constant.HxdConstantsAccount
import com.hxd.mall.network.base.BaseRequest
import com.hxd.mall.network.service.ManagerFunctionApi
import com.hxd.mall.utils.local.HxdSharePreferenceUtil
import com.hxd.mall.utils.open.ToastUtil
import com.hxd.threelibrary.weChat.WeChatUtils

/**
 * 绑定微信工具类
 * 后期加上
 */
object BindWxUtils{
    fun getParamsFromService(context: Context){
        BaseRequest.request(ManagerFunctionApi.mIAccountFunctionApi.flag, {
            if (null == it) return@request
            //从微信获取code,然后把code值传递给后端进行请求
            it.data?.state?.let { state->
                HxdSharePreferenceUtil.saveStringData(HxdConstantsAccount.wx_login_flag, state)
            }
            WeChatUtils().regToWx(context, it?.data?.scope, it?.data?.state)
        }, {
            it.msg?.let { it1 -> ToastUtil.showToast(it1) }
        })

    }



}
